<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"
	contentType="text/html; charset=UTF-8"%>
<%@ page import="shopping.cart.*"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>商品界面</title>

<meta http-equiv="description" content="简单购物车web系统">

</head>

<body>
	<%
		Map<String, Goods> products = new HashMap<String, Goods>();
		ArrayList<Goods> list = new Connect().getAllgoods();
		int num = 1;
		for (Goods e : list)
			products.put(String.valueOf(num++), e);
		session.setAttribute("products", products);
	%>
	<H1 align="center">所有商品信息</H1>

	<form name="form1" action="ShopCartJSP.jsp" method="POST">
		
		<table border="1" cellspacing="0" align="center">
			<tr bgcolor="#CCCCCC">
				<td>商品ID</td>
				<td>商品名称</td>
				<td>商品单价（￥）</td>
				<td>添加到购物车</td>
			</tr>
			<%
				Set productIdSet = products.keySet();
				Iterator it = productIdSet.iterator();
				int number = 1;
				while (it.hasNext()) {
					String id = (String) it.next();
					Goods product = (Goods) products.get(id);
			%><tr>
				<td><%=number++%></td>
				<td><%=product.getName()%></td>
				<td><%=product.getPrice()%></td>
				<td><a href="Buy.jsp?id=<%=product.getId()%>&action=add">加入购物车</a></td>
			</tr>
			<%
				}
			%>

		</table>

		<p></p>
	</form>
</body>
</html>
